/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Marks;

import Admission.AdmissionBean;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Mukesh
 */
public class GetMarksReport extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try { 
            int courseid = 0, sem=0;
            
            if (request.getParameter("stream").length() != 0) {
                courseid = Integer.parseInt(request.getParameter("stream"));
            }
            if (request.getParameter("semester").length() != 0) {
                sem = Integer.parseInt(request.getParameter("semester"));
            }
            
            Vector<Admission.AdmissionBean> list = Subject.Query.getStuList(courseid, sem);
            Iterator it = list.iterator();
            while (it.hasNext()) {
                int i = 1;
                AdmissionBean ab = (AdmissionBean) it.next();
                Student.StudentBean sb = ab.getStudentBean();

                out.println("<tr>");
                out.println("<td>" + sb.getStudentName() + "</td>");
                out.println("<td>" + ab.getRollNumber() + "</td>");
                out.println("<td >");
                out.println("<input type='button' class='btn default' value='View Report' onclick=\"viewAgentDetails('"+ab.getAddmissionId()+"','"+ab.getRollNumber()+"','"+sb.getStudentName()+"')\">");
                out.println("</td>");
                out.println("</tr>");
            }
        } catch (Exception e) {
            out.println(e);
        } finally {
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
